library(readxl)
memb1 <- 
  read_excel("ita_membership_data_van_biezen/data.xlsx", sheet = "memb1") # Not included
memb2 <- 
  read_excel("ita_membership_data_van_biezen/data.xlsx", sheet = "memb2") # Not included
memb3 <- 
  read_excel("ita_membership_data_van_biezen/data.xlsx", sheet = "memb3") # Not included
vote <- 
  read_excel("ita_membership_data_van_biezen/data.xlsx", sheet = "vote") # Not included

require(reshape2)
memb <- rbind(melt(as.data.frame(memb1), id.vars = 'Year'),
              melt(as.data.frame(memb2), id.vars = 'Year'),
              melt(as.data.frame(memb3), id.vars = 'Year'))
memb <- memb[!is.na(memb$value),]

memb <- 
  merge(memb, vote, by.x = c('Year', 'variable'), by.y = c('YearMemb','Party'), all = TRUE)
memb$lbl <- paste0(memb$variable, "\n", memb$Year)


require(viridis)
p_ita_memb_vote <- 
ggplot(memb, aes(value, VoteNum, colour = Year)) +
  geom_point(size = 3) + 
  geom_text(data = subset(memb, VotePerc > 20), aes(value, VoteNum, colour = Year, label = lbl)) +
  geom_smooth(method = 'lm', se = FALSE) +
  scale_colour_gradientn(colours = rev(viridis(9))) +
  theme_bw() +
  geom_point(aes(x=43021, y=8797902), shape = 8, colour = 'black') +
  geom_text(aes(x=43021, y=8797902, label='M5S\n2013'), alpha = 0.8, colour = 'black') +
  scale_x_continuous(label = scales::comma) +
  scale_y_continuous(label = scales::comma) +
  labs(x = "membership", y = 'vote')

# summary(lm(VoteNum ~ value + Year, data = memb))

# FI
## 1998: 7712149/ 140000
## 2007: 9048976 / 401014